package com.qf.office.admin.controller;

import com.qf.office.admin.common.qo.CandidateDetailsQo;
import com.qf.office.admin.common.vo.CandidateDetailsVo;
import com.qf.office.admin.service.CandidateService;
import com.qf.office.common.base.result.ResponseResult;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @className:CandidateController
 * @author:廖广军
 * @date:2024/1/23 17:29
 * @version:1.0
 */
@RestController
@RequestMapping("/candidate")
@Validated
@Slf4j
@Api(tags = "招聘管理API接口")
public class CandidateController {
    @Resource
    private CandidateService candidateService;

    @PostMapping("/add")
    @ApiOperation("增加：添加候选人")
    @ApiImplicitParam(name = "candidateDetailsQo", value = "候选人详情")
    @ApiResponses({@ApiResponse(code = 20000, message = "成功", response = Integer.class), @ApiResponse(code = 40000, message = "未知错误")})
    public ResponseResult<Integer> addCandidateDetailsQo(@RequestBody @Validated CandidateDetailsQo candidateDetailsQo) {
        return ResponseResult.success(candidateService.addCandidateDetails(candidateDetailsQo));
    }


    @GetMapping("list")
    @ApiOperation("查询：查看候选人详细信息")
    @ApiImplicitParam(name = "candidateId",value = "候选人id")
    @ApiResponses({@ApiResponse(code = 20000, message = "成功", response = Integer.class), @ApiResponse(code = 40000, message = "未知错误")})
    public ResponseResult<CandidateDetailsVo> getCandidateDetails(@RequestParam("candidateId") Integer candidateId){
        return ResponseResult.success(candidateService.getCandidateDetails(candidateId));
    }




    @GetMapping("/count")
    @ApiOperation("查询：查询每个候选状态的人数")
    @ApiResponses({@ApiResponse(code = 20000, message = "成功", response = Integer.class), @ApiResponse(code = 40000, message = "未知错误")})
    public ResponseResult<List<Map<String,Integer>>> getCandidateCount(){
        return ResponseResult.success(candidateService.getCandidateCount());
    }


    /**
     * 根据候选的状态，查询所在状态的所有候选人信息，分页,模糊查询
     */

}
